<?php

namespace App\Miya\Models;

use Illuminate\Database\Eloquent\Model;

class SearchRecord extends Model
{
    protected $guarded = [];

    public function setTypesAttribute($value)
    {
        $this->attributes['types'] = $value ? json_encode($value) : '{}';
    }

    public function getTypesAttribute($value)
    {
        return json_decode($value, true);
    }

    public function module()
    {
        return $this->belongsTo(Module::class);
    }
}
